#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

typedef struct BinaryTreeNode
{
    char data;
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
}BTNode;

BTNode* BuyNode(char x)
{
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));

    newnode->data = x;
    newnode->left = NULL;
    newnode->right = NULL;

    return newnode;
}

BTNode* BTreeCreatry(char a[], int* pi)
{
    if (a[(*pi)] == '#')
    {
        pi++;
        return NULL;
    }

    BTNode* root = BuyNode(a[(*pi)++]);

    root->left = BTreeCreatry(a, pi);
    root->right = BTreeCreatry(a, pi);

    return root;
}

void InOrder(BTNode* root)
{
    if (root == NULL)
    {
        return;
    }

    InOrder(root->left);
    printf("%d ", root->data);
    InOrder(root->right);
}

int main() {
   int* p = 1;
    char a[100] = { 0 };
    scanf("%s", a);
    int i = 0;
    BTNode* root = BTreeCreatry(a, &i);
    InOrder(root);
}